/*
 * Copyright 2010 Chad Retz
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package org.jdocng.shared.model;

import javax.xml.bind.annotation.XmlType;

import com.google.common.annotations.GwtCompatible;
import com.google.gson.annotations.Expose;
import com.sun.javadoc.Type;
import com.sun.javadoc.TypeVariable;

/**
 * Implementation of {@link TypeVariable}
 *
 * @author Chad Retz
 */
@XmlType(name = "typeVariable")
@GwtCompatible(serializable = true)
@SuppressWarnings("serial")
public class TypeVariableImpl extends TypeImpl implements TypeVariable {

    //exposed fields
    
    @Expose
    private String[] bounds;
    
    @Expose
    private String owner;
    
    //non-exposed fields
    
    private transient Type[] boundsLoaded;
    
    //TypeVariable interface impl
    
    @Override
    public Type[] bounds() {
        if (boundsLoaded == null) {
            boundsLoaded = getContext().getTypes(bounds);
        }
        return boundsLoaded;
    }
    
    @Override
    public ProgramElementDocImpl owner() {
        throw new UnsupportedOperationException("Not yet...");
    }
    
    //other accessors
    
    public String[] getBounds() {
        return bounds;
    }
    
    public void setBounds(String[] bounds) {
        this.bounds = bounds;
    }
    
    public String getOwner() {
        return owner;
    }
    
    public void setOwner(String owner) {
        this.owner = owner;
    }
}
